﻿Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Seuss.EnterpriseLibrary.DataAccess
Imports Seuss.EnterpriseLibrary.BusinessLogic
Imports System.Web
Imports System.Data

Partial Class Consulta_PA_InfoEcon_TasaEdu_Contenido
    Inherits System.Web.UI.Page
    Dim cPerCodigo As String
    Dim cPerJuridica As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Expires = -1
        Response.AddHeader("Pragma", "no-cache")
        Response.AddHeader("cache-control", "private")
        Response.CacheControl = "no-cache"
        cPerCodigo = Request.QueryString("cPerCodigo")
        cPerJuridica = Request.QueryString("cPerJuridica")
        If Not Page.IsPostBack Then
            lblcPercodigo.Text = cPerCodigo
            lblcPerJuridica.Text = cPerJuridica
            Call CargarTasasEducativas(lblcPerJuridica.Text)
            Using Seguridad As New BLL_Administracion
                Seguridad.Set_Transaccion_Insert(Nothing, 100401, IdentityUser.UserCode, My.Request.UserHostAddress.ToString, CrearXMLTransaccion("Consulta Pagina Movil", "/Pagina|" + My.Request.Url.Segments(My.Request.Url.Segments.Length - 1).ToString))
            End Using
        End If
    End Sub

    Private Sub CargarTasasEducativas(ByVal cPerJuridica As String)
        Dim ldr As New List(Of IDataReader)
        Dim DivPrincipal As New StringBuilder
        Dim BdPremium As String
        BdPremium = CapturaFilialPremium(cPerJuridica)
        DivPrincipal.Append("<table  style='width:100%;'>")

        DivPrincipal.Append("<tr style='color:#FFFFFF'>")
        DivPrincipal.Append("   <td style='background-color:#666666;font-size:10px;width:75%;text-align:center;'>Descripción</td>")
        DivPrincipal.Append("   <td style='background-color:#666666;font-size:10px;text-align:center;'>Monto</td>")
        DivPrincipal.Append("</tr>")

        Using ObjPool As New PoolDbCommand()
            Dim ObjUsuario As New DAL_Kiosco(ObjPool.Database)
            ObjPool.AddDbCommand(ObjUsuario.Get_TasaEducativas_By_cPerJurCodigo(BdPremium), PoolDbCommand.PoolDbCommandResultType.Query)
            ObjPool.Pooling(Nothing, ldr, True)
            ObjUsuario = Nothing
            While ldr(0).Read
                DivPrincipal.Append("<tr>")
                DivPrincipal.Append("   <td style='font-size:10px;width:35%;'>&nbsp&nbsp" + ldr(0).Item("descserv").ToString + "</td>")
                DivPrincipal.Append("   <td style='font-size:10px;text-align:center'>" + ldr(0).Item("montoS").ToString + "</td>")
                DivPrincipal.Append("</tr>")
            End While
        End Using

        DivPrincipal.Append("</table>")
        lblUO.Text = DivPrincipal.ToString
    End Sub

    Private Function CapturaFilialPremium(ByVal cPerJuridica As String) As String
        Dim lDrd As New List(Of IDataReader)
        Dim FilialPremium As String = ""

        Using objPool As New PoolDbCommand()
            Dim objDal As New DAL_Kiosco(objPool.Database)
            objPool.AddDbCommand(objDal.Get_cPerIdeNumero(cPerJuridica, 90001), PoolDbCommand.PoolDbCommandResultType.Query)
            objPool.Pooling(Nothing, lDrd, True)
            If lDrd.Count > 0 Then
                If lDrd(0).Read Then
                    FilialPremium = lDrd(0).Item("cPerIdeNumero").ToString
                End If
            End If
            lDrd(0).Close()
            lDrd(0) = Nothing
        End Using
        Return FilialPremium
    End Function
End Class
